<?php
namespace app\common\model;

class CheckApprove extends Base
{
    public static function getApproveInfo($userId = 0)
    {
        $userInfo = User::getFind(['id' => $userId]);
        $info     = CheckApprove::getFind(['section_id' => $userInfo['section_id']], 'id, approve_id, send_id');

        $info['approve'] = User::getFind(['id' => $info['approve_id']], 'name, avatars');
        $info['send']    = User::getFind(['id' => $info['send_id']], 'name, avatars');

        return $info;
    }

    /**
     * 查询是否本部门审批人
     */
    public static function isApprove($userId = 0)
    {
        $isBe = false;
        $userInfo = User::getFind(['id' => $userId]);
        if(!$userInfo) return $isBe;

        $approveInfo = self::getFind(['section_id' => $userInfo['section_id']]);
        if(!$approveInfo) return $isBe;

        if($approveInfo['approve_id' == $userId]) $isBe = true;

        return $isBe;
    }
}